package com.x.Part10_valueTransfer;

/**
 * ClassName: ValueTranferTest2
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2023/9/19 1:46
 */
public class ValueTranferTest2 {
    public static void main(String[] args) {
        Date d1 = new Date();
        d1.m = 10;
        d1.n = 20;

        //方式1:数值传递
//      int temp = d1.m;
//      d1.m = d1.n;;
//      d1.n = temp;


        //方式2：方法传递
        ValueTranferTest2 test = new ValueTranferTest2();
        test.swap(d1);//交换成功
        System.out.println(d1.m);
        System.out.println(d1.n);

    }

    public void swap(Date date){
        int temp = date.m;
        date.m = date.n;
        date.n = temp;
    }
}

class Date{
    int m;
    int n;
}
